import cn.gudian.cms.Admin.AdminRole
import cn.gudian.cms.Admin.AdminUser
import cn.gudian.cms.System.SysConfig

class BootStrap {

  def init = {servletContext ->
//    System.setProperty("file.encoding", "UTF-8")
//    System.setProperty("default.client.encoding", "UTF-8")
//    System.setProperty("user.language", "zh")
//    System.setProperty("user.region", "CN")
    AdminRole adminRole
    AdminUser mem
    if (!AdminRole.findByName("超级管理员")) {
      adminRole = new AdminRole(name: "超级管理员", roles: "SYSTEM_ADMIN,ARCHIVES_ADD");
      adminRole.save()
    }
    if (!AdminUser.findByUserName("admin")) {
      mem = new AdminUser(adminRole: adminRole, userName: "admin", password: "e807f1fcf82d132f9bb018ca6738a19f", realName: "李四", mobile: "15887004850", email: "vottot@gmail.com", arcTypeIDs: "1,2", loginNum: 1, lastLoginTime: new Date(), lastLoginIP: "127.0.0.1").save();
    }
    if (!SysConfig.list()) {
      new SysConfig(varName: "COMPANY_NAME", info: "公司名称", groupID: "1", varType: "text", varValue: "古滇科技").save();
      new SysConfig(varName: "LINK_TEL", info: "联系电话", groupID: "1", varType: "text", varValue: "+86 0871-5521800").save();
      new SysConfig(varName: "LINK_EMAIL", info: "电子邮箱", groupID: "1", varType: "text", varValue: "admin@gudkj.com").save();
      new SysConfig(varName: "LINK_ADDRESS", info: "联系地址", groupID: "1", varType: "text", varValue: "云南省昆明市").save();
      new SysConfig(varName: "SITE_NAME", info: "网站名称", groupID: "1", varType: "text", varValue: "云南东艺电气工业有限公司").save();
      new SysConfig(varName: "SITE_KEYWORDS", info: "网站关键词", groupID: "1", varType: "textArea", varValue: "云南东亿电器工业有限公司  云南东亿电器   汽车线束  曲靖东亿 曲靖开关厂   电器线束   汽车配件  电线线束   低压电线线束").save();
      new SysConfig(varName: "SITE_DESCRIPTION", info: "网站描述", groupID: "1", varType: "textArea", varValue: "网站设计，三维动画").save();
      new SysConfig(varName: "BOOKING_MOBILE", info: "接收预订提示手机号码", groupID: "2", varType: "text", varValue: "13888542543").save();
      new SysConfig(varName: "SMS_SOFTWARESERIALNO", info: "短信系列号", groupID: "2", varType: "text", varValue: "0SDK-EMY-0130-KISSO").save();
      new SysConfig(varName: "SMS_PASSWORD", info: "短信系列号密码", groupID: "2", varType: "text", varValue: "698099").save();
      new SysConfig(varName: "SITE_WATERIMG", info: "水印图片", groupID: "3", varType: "text", varValue: "/images/water.png").save();
      new SysConfig(varName: "SITE_WATERPOSITION", info: "水印位置：center,leftUp,leftDown,rightUp,rightDown,all,leftUpAbs,leftDownAbs,rightUpAbs,rightDownAbs", groupID: "3", varType: "text", varValue: "rightDownAbs").save();
    }
  }
  def destroy = {
  }
} 